package game.components;

import java.awt.Graphics2D;

import com.uqbar.vainilla.GameComponent;

public abstract class WorldSprite extends GameComponent<MatchScene> {
	
	public WorldSprite(double x, double y) {
		super(x,y);
	}
	
	public boolean isWithinTheCamera() {
		Camera camera = this.getScene().getCamera();
		return this.getX() + this.getAppearance().getWidth() >= camera.getX() &&
				this.getX() <= camera.getX() + camera.getWidth() &&
				this.getY() + this.getAppearance().getHeight() >= camera.getY() &&
				this.getY() <= camera.getY() + camera.getHeight();
	}
	
	@Override
	public void render(Graphics2D graphics) {
		if (this.isWithinTheCamera())
			super.render(graphics);
	}	
}
